package ldh.im.fxgui;

import ldh.im.fxgui.rpc.service.ImCommunicateService;
import ldh.im.util.ConfigUtil;
import ldh.rpc.RpcConfig;
import ldh.rpc.cache.LocalRpcCacheService;
import ldh.rpc.client.RpcClientBootstrap;
import ldh.rpc.client.RpcClientWebSocketBootstrap;

public class WebsocketMainApp extends MainApp {

    @Override
    protected RpcClientBootstrap createClientBootstrap() throws InterruptedException {
        String address = ConfigUtil.getString("websocket.address");
        int port = ConfigUtil.getInt("websocket.port", 9290);
        RpcConfig rpcConfig = new RpcConfig(new LocalRpcCacheService("client-websocket"), address, port, "binary");
        rpcConfig.setCommunicateService(new ImCommunicateService(rpcConfig));

        RpcClientBootstrap clientBootstrap = new RpcClientWebSocketBootstrap(rpcConfig, "imWebsocket");
        return clientBootstrap;
    }
}
